import { ContentType } from '@/enums/httpEnum';
import { request } from '@umijs/max';

//获取所有路线名称
export async function getRouteNames() {
  return request<API.Result>('/api/inspection/patrolRoute/allName', {
    method: 'GET'
  });
}

// 查询路线信息列表
export async function getRouteList(params?: API.Manage.RouteListParams) {
  return request<API.Manage.RoutePageResult>('/api/inspection/patrolRoute/list', {
    method: 'GET',
    headers: { 'Content-Type': ContentType.FORM_URLENCODED },
    params
  });
}


//新增路线
export function addRoute(params: API.Manage.Route) {
  return request<API.Result>('/api/inspection/patrolRoute/add', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json;charset=UTF-8',
    },
    data: params,
  });
}

//更新路线
export function updateRoute(params: API.Manage.Route) {
    return request<API.Result>('/api/inspection/patrolRoute/update', {
      method: 'POST',
      headers: {
          'Content-Type': 'application/json;charset=UTF-8',
      },
      data: params,
    });
  }

// 删除路线信息
export async function removeRoute(ids: number[]) {
  return request<API.Result>('/api/inspection/patrolRoute/delete', {
    method: 'POST',
    data: ids
  });
}

//生成路线ID
export async function generateRouteId() {
  return request<API.Manage.ResultID>('/api/inspection/patrolRoute/generateId', {
    method: 'GET'
  });
}

//获取点位信息
export async function getPointList() {
  return request<API.Manage.PointResult>('/api/inspection/patrolPoint/list', {
    method: 'GET',
    headers: { 'Content-Type': ContentType.FORM_URLENCODED },
  });
}

//新增点位
export function addPoint(params: API.Manage.RoutePoint) {
  return request<API.Result>('/api/inspection/routePoint/add', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json;charset=UTF-8',
    },
    data: params,
  });
}

//根据路线ID获取点位信息
export async function getPointsByRouteId(routeId: number) {
  return request<API.Result>(`/api/inspection/routePoint/${routeId}`, {
    method: 'GET',
    headers: { 'Content-Type': ContentType.FORM_URLENCODED },
    data: { routeId }
  });
}

